﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using YTCMS.Services.Services;
using YTCMS.Core;

namespace App.Controllers
{
    public class HomeController : Controller
    {
        private readonly IproductsService _product;
        private readonly ImoduleService _module;
        private readonly IcmscolumnService _cmscolumn;
        private readonly IcolumnproductService _columnproducts;
        private readonly IcategoryService _categoey;
        public HomeController(IproductsService product, IcmscolumnService cmscolumn, IcolumnproductService columnproducts, ImoduleService module, IcategoryService categoey)
        {
            this._product = product;
            this._cmscolumn = cmscolumn;
            this._columnproducts = columnproducts;
            this._module = module;
            this._categoey = categoey;
        }
        //
        // GET: /Home/
        public ActionResult Index()
        {

            var theme = App.Common.ThemeManager.Theme;
            if (theme.ToLower() == "cms")
            {
                ViewData["categorys"] = _categoey.GetMany(s => s.State == (int)CommonState.正常);
                var code = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
                var columns = _cmscolumn.GetMany(s => s.State == (int)CommonState.正常 && s.module.Code.Equals(code) && s.module.Type.Equals("PC"), Order.desc, "Sort");
                return View(columns);
            }
            else {
                var code = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
                var columns = _cmscolumn.GetMany(s => s.State == (int)CommonState.正常 && s.module.Code.Equals(code), Order.desc, "Sort");
                return View(columns);
            }

            
            //var columnproducts = _columnproducts.GetMany(s => s.State == (int)CommonState.正常);
            
        }
	}
}